package org.windey.server;

import java.net.Socket;

import org.windey.Debug;

/**
 * 
 * connectie tussen applet en server leggen
 *
 */
public class AppletConnection extends WindeyConnection
{	
	/**
	 * 
	 * @param socket
	 */
	public AppletConnection(Socket socket)
	{
		super(socket);
	}
	
	/**
	 * 
	 */
	public void run()
	{
		if (isRunning())
		{
			Debug.debug("appletconnection established (" + getSocket().getInetAddress().getHostAddress() + ")");
			String key = receive();
			Debug.debug("connectionKey : " + key);
			ClientConnection cc = WindeyServer.getServer().getClientConnection(key);
			if (cc != null)
			{
				Debug.debug("applet/client linked");
				cc.setAppletConnection(this);
				WindeyStreamThread wst = new WindeyStreamThread(this, cc);
				send("WindeyStartStream");
				wst.start();
			}
		}
	}
}
